package gb28181_client

import (
	"context"

	"gb28181/gb28181"

	"github.com/zeromicro/go-zero/zrpc"
)

type Client struct {
	conn zrpc.Client
}

func NewClient(zrpcClient zrpc.Client) *Client {
	return &Client{
		conn: zrpcClient,
	}
}

// Ping 基础测试接口
func (c *Client) Ping(ctx context.Context, req *gb28181.Request) (*gb28181.Response, error) {
	client := gb28181.NewGb28181Client(c.conn.Conn())
	return client.Ping(ctx, req)
}

// RegisterDevice 注册GB28181设备
func (c *Client) RegisterDevice(ctx context.Context, req *gb28181.DeviceRegisterRequest) (*gb28181.DeviceRegisterResponse, error) {
	client := gb28181.NewGb28181Client(c.conn.Conn())
	return client.RegisterDevice(ctx, req)
}

// Heartbeat 设备心跳
func (c *Client) Heartbeat(ctx context.Context, req *gb28181.DeviceHeartbeatRequest) (*gb28181.DeviceHeartbeatResponse, error) {
	client := gb28181.NewGb28181Client(c.conn.Conn())
	return client.Heartbeat(ctx, req)
}

// QueryDevice 查询设备信息
func (c *Client) QueryDevice(ctx context.Context, req *gb28181.DeviceQueryRequest) (*gb28181.DeviceQueryResponse, error) {
	client := gb28181.NewGb28181Client(c.conn.Conn())
	return client.QueryDevice(ctx, req)
}

// ListDevices 列出设备列表
func (c *Client) ListDevices(ctx context.Context, req *gb28181.DeviceListRequest) (*gb28181.DeviceListResponse, error) {
	client := gb28181.NewGb28181Client(c.conn.Conn())
	return client.ListDevices(ctx, req)
}

// RealPlay 实时视频播放
func (c *Client) RealPlay(ctx context.Context, req *gb28181.RealPlayRequest) (*gb28181.RealPlayResponse, error) {
	client := gb28181.NewGb28181Client(c.conn.Conn())
	return client.RealPlay(ctx, req)
}

// Playback 录像回放
func (c *Client) Playback(ctx context.Context, req *gb28181.PlaybackRequest) (*gb28181.PlaybackResponse, error) {
	client := gb28181.NewGb28181Client(c.conn.Conn())
	return client.Playback(ctx, req)
}

// PTZControl PTZ云台控制
func (c *Client) PTZControl(ctx context.Context, req *gb28181.PTZControlRequest) (*gb28181.PTZControlResponse, error) {
	client := gb28181.NewGb28181Client(c.conn.Conn())
	return client.PTZControl(ctx, req)
}